%AC 12/19
function [NI]=NI_initialize
disp('Searching for devices') ;
daqreset ;
daq_devices = daq.getDevices;
if isempty(daq_devices)
    disp('No NI device found...') ;
    return
end
NI_ID = daq_devices.ID ; % daq_devices(1).ID ;
srate=10;
%
disp('Initializing the NI device. This may take a few seconds.');
%create the session
NI=daq.createSession('ni');

%set the DAQ samplingrate to 10000 Hz
NI.Rate=srate;

%Add analog output channels
addAnalogOutputChannel(NI,NI_ID,2,'Voltage');%trigger EEG
addAnalogOutputChannel(NI,NI_ID,1,'Voltage'); %trigger TCS
%addAnalogOutputChannel(NI,NI_ID,0,'Voltage'); %trigger VAS

%Add five analog input channels
addAnalogInputChannel(NI,NI_ID,0,'Voltage'); %get VAS input
%addInput(NI, NI_ID,0, 'Voltage');% get input VAS



disp('Initialized!');
end
